<?php

class cntrlactivate implements viewController {

	private $area;
	private $side;
	private $dependencies = array("CSS" => array("hideSidebar.css") );
	private $pageName = "Account activation";

	public function __construct(user &$userObj){
		parse_str( $_GET['act'] );
		
		// Has the invite string been set
		if(isset($i)){
		
			// Does the hash match a hash in the system?	
			$user = invite::match_hash($i);
			
			// If its not in the system give the user an error page
			if(is_null($user)) header("Location: error?id=3");
			
			// Activate the account.
			if( invite::activateAccount($user['email'], $i) ){				
				
				// Check to see if there is any additional information we need to parse for this username & add to their account (previous pending memberships etc)
				
				// Parse information into the page
				$message 	= new template('area.activationmessage');
				$login 		= new template('area.biglogin');

				$storedUser = users::getUser( $user['email']);

				$login->replace('username', $storedUser['userName']);
				
				$this->area = $message . $login;
			} else {
				header("Location: error?id=4");
			}
		} else {
			header("Location: home");
		}
	}
	
	
	public function getSide(){
		return $this->side;
	}
	
	public function getArea(){
		return $this->area;
	}
	
	public function getDependencies(){
		return $this->dependencies;
	}

	public function getPageName(){
		return $this->pageName;
	}
	
	public function getTools(){
		return "";
	}	
	
}

?>